#ifndef _GameMain_H_
#define _GameMain_H_

#include "Define.h"
#include "State\\GameState.h"
#include "State\\TitleState.h"
#include "State\\StateManager.h"
#include "Network\Structure.h"

#include <d3dx9.h>


class TextureManager;
class GameMain
{
public:

	GameMain();
	~GameMain();

	bool Create( HINSTANCE Inst,  HINSTANCE hPrevInstance, LPSTR lpCmdLine, int iCmdShow );
	void GameLoop();
	void Release();

	static GameMain *GetInstance() { return m_pkThis; }



protected:
	
	static GameMain *m_pkThis;
	static LRESULT CALLBACK WinProc( HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam );

	//-----------------------------------------------------
	// Main Function
	//-----------------------------------------------------
	bool MakeWindows( HINSTANCE Inst, int iCmdShow  );
	bool InitD3D();
	bool InitTexture();

	void Update( unsigned int dt );
	void Render();

	void NetworkRecv( char *Buf );
	bool NetworkInit();


	void OnNetworkMessage( LPARAM lParam );


	// State Manager
	StateManager			*StateMgr;
	TextureManager			*TextureMgr;

	IDirect3D9				*m_pkD3D;
	IDirect3DDevice9		*m_pkDevice;
	HWND					m_hWnd;
	HINSTANCE				m_hInstance;
	SOCKET					m_socket;

	char					*m_pcProjectName;
	char					m_cTempBuf[ BUFFER_SIZE ];
	char					m_cRecvBuf[ BUFFER_SIZE ];
	int						m_iRecvData;
	int						m_iState;



};






#endif // endif 